/*
 * SmartPointer.h
 *
 *  Created on: 11.03.2012
 *      Author: ignacio
 */

#ifndef SMARTPOINTER_H_
#define SMARTPOINTER_H_

#include <boost/smart_ptr.hpp>

//
// ****************
// * SmartPointer *
// ****************
//
namespace neurignacio
{
	template <typename Type> class SmartPointer : public boost::shared_ptr<Type>	// Definition for the basic Smart Pointer type (i.e. boost::shared_ptr)
	{
	public:
		SmartPointer(Type* pointer) : boost::shared_ptr<Type>(pointer) {} // pointer should refer to a dynamic memory address
	};

	template <typename Type> class BasePointer
	{
	protected:
		Type* pointer;
	public:
		BasePointer() : pointer(0) {}
		BasePointer(const Type* ptr) : pointer(ptr) {}
		BasePointer(const Type& object) : pointer(&object) {}
		bool operator==(const BasePointer<Type>& rhs) const {return pointer==rhs.pointer;}
		bool operator!=(const BasePointer<Type>& rhs) const {return pointer!=rhs.pointer;}
		Type* operator->() const {return *pointer;}
		Type& operator*() const {return pointer;}
	};

	template <typename Type> class Pointer : public SmartPointer<Type> {}; 	// Definition of what I will understand from now on as Pointer type (i.e. normal pointer Type* or smart pointer
	// defines NULL Pointer
	class {	public: template<typename T> operator Pointer<T>() { return Pointer<T>(); } } NULL_POINTER;

} // end namespace neurignacio


#endif /* SMARTPOINTER_H_ */
